<html>
<head>
  <meta charset="UTF-8">
  <title>usercontroller</title>
</head>
<body>
  <?php 
  require 'Controller.php';
  require 'Admin/Model/UserModel.php';
  
  class UserController extends Controller{
  
    function __construct(){
      parent::__construct();
    }
    function listusers(){
      /*data=array(array('uname'=>'zhangsan','sex'=>'male'),array('uname'=>'lisi','sex'=>'female'));*/
      $model=new UserModel();
      $data=$model->getUserList();

      $this->assign('user',$data);
      $this->display();
      /*return $data;
*/    }

 function menu()
 {

  $this->display();

 }



      function deluser(){
        $uid=$_GET['uid'];
        $model=new UserModel();
        $result=$model->delUser($uid);
        if($result){
          echo "删除成功！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=user&m=listusers'");
        }
        else{
          echo "删除失败！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=user&m=listusers'");
        }
      }
      function reguser(){
        $this->display();
      }
      function adduser(){
        $data=$_POST;
      /*  var_dump($data);*/
        $file=$_FILES;
        $model=new UserModel();
        $result=$model->adduser($data,$file);
        if ($result) {
          echo "注册成功,欢迎登陆";
          header("refresh:3;url='index.php?c=index&m=index'");
        }else{
          echo "注册失败,3秒后返回注册也重新注册";
         header("refresh:3;url='admin.php?c=user&m=reguser'");
        }
      }
      function editUser(){
        $uid=$_GET['uid'];
        $model=new UserModel();
        $data=$model->editUser($uid);
        $this->assign('user',$data);
          $this->display();
      }
      function updateuser(){
        $data=$_POST;
        $file=$_FILES;
        $model=new UserModel();
        $result=$model->updateuser($data,$file);
        if($result){
          echo "修改成功！三秒后就跳转用户列表页";
          header("refresh:3;url='admin.php?c=user&m=listusers'");
        }
        else{
          echo "修改失败！三秒后就跳转用户列表页";
          header("refresh:3;url='index.php?c=user&m=listusers'");
        }
      }
  }

   ?>
</body>
</html>
